package com.dx.gate.service;

import com.alibaba.nacos.api.utils.NetUtils;
import com.dx.cache.cache.DmpRedisCache;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * 实现节点的更新
 *
 * @author xufeng
 * @since 18.04.2023
 */
@Service("imWorkerManager")
public class ImWorkerManagerImpl implements ImWorkerManager{
    @Value("${netty.port}")
    private int nettyPort;
    @Value("${dubbo.protocol.port}")
    private int dubboPort;
    @Resource
    DmpRedisCache dmpRedisCache;

    /**
     * 用户和工作节点信息存入redis
     */
    @Override
    public void register(String userId) {
        Map<Object,Object> map = new HashMap<>();
        map.put("ip",NetUtils.localIP());
        map.put("nettyPort",nettyPort);
        map.put("dubboPort",dubboPort);
        dmpRedisCache.hMset(userId,map);
    }

    @Override
    public void shuntDown(String userId) {

    }
}
